<%@ page language="java" import="java.util.*" 
		import="com.javaweb.common.StringTool"
		import="com.javaweb.entity.User"
		pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="css/main.css">
	
   <style type="text/css">

	.content1 {
	
		width:99%;
		height:auto;
		margin:0;
		padding:0 0 0 10px;
		border:5px solid #EEEEEE;
		
	}
	
	
	</style>
  </head>
  
  <body>
  
  
  <% 
  	/*String msg = "hello!";
  	session.setAttribute("msg", msg);*/
  	User user = new User();
  	user.setId(1001);
  	user.setName("张三");
  	
  	pageContext.setAttribute("msg", "hello in pageContext");
  	request.setAttribute("msg", "hello in requestScope");
  	session.setAttribute("msg","hello in sessionScope");
  	application.setAttribute("msg", "hello in applicationScope");
  	// 在session中有属性名叫 user 
  	session.setAttribute("user", user);
  	
  	
  %>

    <div class="main">
    	<jsp:include page="head.jsp"/>
    	<div class="content">
    		<div class="content1">
    			<h3> . 和 [] 运算符号</h3>
    			<hr>
    			<h3> 算术运算 </h3>
    			\${1+2 }= ${1+2 }
    			<br><hr>
    			<h3>关系运算</h3>
				\${1>2 }=${1>2 }
				<br><hr>
				<h3>条件运算</h3>
				\${1>2 && 2>1 }=${1>2 && 2>1 }
				<br><hr>
				<h3>empty 运算</h3>
				\${empty user }=${empty user }
				<br><hr>
				<h3>条件表达式</h3>
				\${not empty user?"user is not null":"user is null" }=${ not empty user? "user is not null":"user is null"}
				<br>
			</div><br>
			
    		


    		<div class="content1">        ${msg }
    			<h3>访问四种属性范围中的数据</h3>
    			\${pageScope['msg']} = ${pageScope.msg }
    			<br>
    			\${requestScope.msg} = ${requestScope.msg}
    			<br>
    			\${sessionScope.msg} = ${sessionScope.msg}
    			<br>
    			\${applicationScope.msg} = ${applicationScope.msg}
    			<br>
    			\${msg} = ${msg }<br>
    			username  = ${user.name }<br>
    			username = ${sessionScope.user.name }<br>
    	
    		</div><br>
    		
    		
    		<div class="content1">  
    			<h3>调用内置对象</h3>
    			IP地址：${pageContext.request.remoteAddr}<br>
    			SessionID: ${pageContext.session.id}<br>
    			
    			
    		</div><br><hr>
    		
    		
    		<div class="content1">  
    			<h3>接收请求参数</h3>
    			
    			通过内置对象接收请求的输入参数：<%= request.getParameter("username")%> <br>
    			通过表达式语言接收请求的输入参数：${param.username} <br>
    			
    		</div><br>
    		
    		 
    			<div class="content1">  
    			<h3>接收一组请求参数</h3>
    			<form action="${pageContext.request.contextPath}/beforeClass/jsptag/showEL.jsp" method="post">
    			
    			<input type="checkbox" name="inst" value="唱歌">唱歌
    			<input type="checkbox" name="inst" value="跳舞">跳舞
    			<input type="checkbox" name="inst" value="游泳">游泳
    			<input type="checkbox" name="inst" value="读书">读书
    			
    			<input type="submit" value="提交" />
    			</form><br>
    			
    			你的兴趣是：<br>
    			${paramValues.inst[0]};${paramValues.inst[1]};
    			${paramValues.inst[2]};${paramValues.inst[3]}; 
    			
    			
    			
    			
    		</div><br>
    			
    		<div class="content1">  
    			<h3>Collection操作</h3>
    		
    			 <%
    			 	Set<String> mySet = new HashSet<String>();
    			    List<String> myList = new ArrayList<String>();
    			    myList.add("item1") ;
    			    myList.add("item2") ;
    			    myList.add("item3") ;
    			    myList.add("item4") ;
    			    session.setAttribute("myList", myList);
    			   
    			 	mySet.add("item1");  
    			    mySet.add("item2");
    			    mySet.add("item3");
    			    mySet.add("item4");
    			    mySet.add("item5");
    			    session.setAttribute("mySet", mySet);
    			    String myString = "张三" ;
    			    
    			  	pageContext.setAttribute("numString",myString);
    			    
    			 %>
    			
    			 该list中包含的数据是：<br>
    			 ${sessionScope.myList[0] },${sessionScope.myList[1] },
    			 ${sessionScope.myList[2] },${sessionScope.myList[3] }.<br><hr>
    			 
    			 该set中包含的数据是：<br>
    			<c:forEach var="item" items="${sessionScope.mySet}" varStatus="status">
    				
    				${item }<br>
    			
    			</c:forEach>
    		    
    			
    		</div><br>
    		
    		
    		<div class="content1">  
    			<h3>Map操作</h3>
    			<%
    				Map<String, String> myMap = new HashMap<String, String>();
    			    myMap.put("1", "item1");
    			    myMap.put("2", "item2");
    			    myMap.put("3", "item3");
    			    myMap.put("4", "item4");
    			    session.setAttribute("myMap", myMap);
     			%>
     			MyMap中的数据是：<br>
     			 ${sessionScope.myMap['1'] }<br>
     			 ${sessionScope.myMap["2"] }<br>
     			 ${sessionScope.myMap["3"] }<br>
				MyMap中的数据是：<br>
				<c:forEach items="${myMap}" var="item" varStatus="status">
					[${status.index} ]  key: ${item.key} - value : ${item.value} <br>
				</c:forEach>
    		</div><br>
    		<div class="content1">  
    		 <h3>访问Cookie</h3>
    			
    		    cookie中的user属性值：${cookie.freelogin.value}
    			
    		</div><br>
    		
    	
    	
    	</div>
    	
    	
    
    	<jsp:include page="copyright.jsp" />
    
    </div>
  </body>
</html>
